﻿namespace UnityEditor
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.IO;
    using System.Runtime.CompilerServices;
    using System.Text;
    using UnityEditorInternal;
    using UnityEngine;

    internal class BuildPlayerWindow : EditorWindow
    {
        private int initialSelectedLVItem = -1;
        private const string kAssetsFolder = "Assets/";
        private const string kEditorBuildSettingsPath = "Library/Versioned/EditorBuildSettings.asset";
        private ListViewState lv = new ListViewState();
        private static BuildPlatforms s_BuildPlatforms;
        private Vector2 scrollPosition = new Vector2(0f, 0f);
        private bool[] selectedBeforeDrag;
        private bool[] selectedLVItems = new bool[0];
        private static Styles styles;

        public BuildPlayerWindow()
        {
            base.position = new Rect(50f, 50f, 540f, 530f);
            base.minSize = new Vector2(550f, 580f);
            base.title = "Build Settings";
        }

        private void ActiveBuildTargetsGUI()
        {
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(255f) };
            GUILayout.BeginVertical(options);
            GUILayout.Label(styles.platformTitle, styles.title, new GUILayoutOption[0]);
            this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition, "OL Box");
            for (int i = 0; i < 2; i++)
            {
                bool flag = i == 0;
                bool flag2 = false;
                foreach (BuildPlatform platform in s_BuildPlatforms.buildPlatforms)
                {
                    if ((IsBuildTargetGroupSupported(platform.DefaultTarget) == flag) && (IsBuildTargetGroupSupported(platform.DefaultTarget) || platform.forceShowTarget))
                    {
                        this.ShowOption(platform, platform.title, !flag2 ? styles.oddRow : styles.evenRow);
                        flag2 = !flag2;
                    }
                }
                GUI.contentColor = Color.white;
            }
            GUILayout.EndScrollView();
            GUILayout.EndVertical();
            GUILayout.Space(10f);
            BuildTarget target = CalculateSelectedBuildTarget();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUI.enabled = BuildPipeline.IsBuildTargetSupported(target) && (BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget) != BuildPipeline.GetBuildTargetGroup(target));
            GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(110f) };
            if (GUILayout.Button(styles.switchPlatform, optionArray2))
            {
                EditorUserBuildSettings.SwitchActiveBuildTarget(target);
            }
            GUI.enabled = BuildPipeline.IsBuildTargetSupported(target);
            GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.Width(110f) };
            if (GUILayout.Button(new GUIContent("Player Settings..."), optionArray3))
            {
                Selection.activeObject = Unsupported.GetSerializedAssetInterfaceSingleton("PlayerSettings");
            }
            GUILayout.EndHorizontal();
            GUI.enabled = true;
            GUILayout.EndVertical();
        }

        private void ActiveScenesGUI()
        {
            int num;
            int num2;
            int num3 = 0;
            int row = this.lv.row;
            bool shift = Event.current.shift;
            bool actionKey = EditorGUI.actionKey;
            Event current = Event.current;
            Rect position = GUILayoutUtility.GetRect(styles.scenesInBuild, styles.title);
            ArrayList list = new ArrayList(EditorBuildSettings.scenes);
            this.lv.totalRows = list.Count;
            if (this.selectedLVItems.Length != list.Count)
            {
                Array.Resize<bool>(ref this.selectedLVItems, list.Count);
            }
            int[] numArray = new int[list.Count];
            for (num = 0; num < numArray.Length; num++)
            {
                EditorBuildSettingsScene scene = (EditorBuildSettingsScene) list[num];
                numArray[num] = num3;
                if (scene.enabled)
                {
                    num3++;
                }
            }
            IEnumerator enumerator = ListViewGUILayout.ListView(this.lv, ListViewOptions.wantsExternalFiles | ListViewOptions.wantsReordering, styles.box, new GUILayoutOption[0]).GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    ListViewElement element = (ListViewElement) enumerator.Current;
                    EditorBuildSettingsScene scene2 = (EditorBuildSettingsScene) list[element.row];
                    bool flag3 = File.Exists(scene2.path);
                    EditorGUI.BeginDisabledGroup(!flag3);
                    bool on = this.selectedLVItems[element.row];
                    if (on && (current.type == EventType.Repaint))
                    {
                        styles.selected.Draw(element.position, false, false, false, false);
                    }
                    if (!flag3)
                    {
                        scene2.enabled = false;
                    }
                    Rect rect2 = new Rect(element.position.x + 4f, element.position.y, styles.toggleSize.x, styles.toggleSize.y);
                    EditorGUI.BeginChangeCheck();
                    scene2.enabled = GUI.Toggle(rect2, scene2.enabled, string.Empty);
                    if (EditorGUI.EndChangeCheck() && on)
                    {
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (this.selectedLVItems[i])
                            {
                                ((EditorBuildSettingsScene) list[i]).enabled = scene2.enabled;
                            }
                        }
                    }
                    GUILayout.Space(styles.toggleSize.x);
                    string path = scene2.path;
                    if (path.StartsWith("Assets/"))
                    {
                        path = path.Substring("Assets/".Length);
                    }
                    Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.TempContent(path), styles.levelString);
                    if (Event.current.type == EventType.Repaint)
                    {
                        styles.levelString.Draw(rect, EditorGUIUtility.TempContent(path), false, false, on, false);
                    }
                    if (scene2.enabled)
                    {
                        GUI.Label(new Rect(rect.xMax - 18f, rect.y, 18f, rect.height), numArray[element.row].ToString());
                    }
                    EditorGUI.EndDisabledGroup();
                    if ((ListViewGUILayout.HasMouseUp(element.position) && !shift) && !actionKey)
                    {
                        if (!shift && !actionKey)
                        {
                            ListViewGUILayout.MultiSelection(row, element.row, ref this.initialSelectedLVItem, ref this.selectedLVItems);
                        }
                    }
                    else if (ListViewGUILayout.HasMouseDown(element.position))
                    {
                        if ((!this.selectedLVItems[element.row] || shift) || actionKey)
                        {
                            ListViewGUILayout.MultiSelection(row, element.row, ref this.initialSelectedLVItem, ref this.selectedLVItems);
                        }
                        this.lv.row = element.row;
                        this.selectedBeforeDrag = new bool[this.selectedLVItems.Length];
                        this.selectedLVItems.CopyTo(this.selectedBeforeDrag, 0);
                        this.selectedBeforeDrag[this.lv.row] = true;
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable == null)
                {
                }
                disposable.Dispose();
            }
            GUI.Label(position, styles.scenesInBuild, styles.title);
            if (GUIUtility.keyboardControl == this.lv.ID)
            {
                if ((Event.current.type == EventType.ValidateCommand) && (Event.current.commandName == "SelectAll"))
                {
                    Event.current.Use();
                }
                else if ((Event.current.type == EventType.ExecuteCommand) && (Event.current.commandName == "SelectAll"))
                {
                    for (num = 0; num < this.selectedLVItems.Length; num++)
                    {
                        this.selectedLVItems[num] = true;
                    }
                    this.lv.selectionChanged = true;
                    Event.current.Use();
                    GUIUtility.ExitGUI();
                }
            }
            if (this.lv.selectionChanged)
            {
                ListViewGUILayout.MultiSelection(row, this.lv.row, ref this.initialSelectedLVItem, ref this.selectedLVItems);
            }
            if (this.lv.fileNames != null)
            {
                Array.Sort<string>(this.lv.fileNames);
                int num6 = 0;
                for (num = 0; num < this.lv.fileNames.Length; num++)
                {
                    if (this.lv.fileNames[num].EndsWith("unity"))
                    {
                        EditorBuildSettingsScene scene3 = new EditorBuildSettingsScene {
                            path = FileUtil.GetProjectRelativePath(this.lv.fileNames[num])
                        };
                        if (scene3.path == string.Empty)
                        {
                            scene3.path = this.lv.fileNames[num];
                        }
                        scene3.enabled = true;
                        list.Insert(this.lv.draggedTo + num6++, scene3);
                    }
                }
                if (num6 != 0)
                {
                    Array.Resize<bool>(ref this.selectedLVItems, list.Count);
                    for (num = 0; num < this.selectedLVItems.Length; num++)
                    {
                        this.selectedLVItems[num] = (num >= this.lv.draggedTo) && (num < (this.lv.draggedTo + num6));
                    }
                }
                this.lv.draggedTo = -1;
            }
            if (this.lv.draggedTo != -1)
            {
                ArrayList c = new ArrayList();
                num2 = 0;
                num = 0;
                while (num < this.selectedLVItems.Length)
                {
                    if (this.selectedBeforeDrag[num])
                    {
                        c.Add(list[num2]);
                        list.RemoveAt(num2);
                        num2--;
                        if (this.lv.draggedTo >= num)
                        {
                            this.lv.draggedTo--;
                        }
                    }
                    num++;
                    num2++;
                }
                this.lv.draggedTo = ((this.lv.draggedTo <= list.Count) && (this.lv.draggedTo >= 0)) ? this.lv.draggedTo : list.Count;
                list.InsertRange(this.lv.draggedTo, c);
                for (num = 0; num < this.selectedLVItems.Length; num++)
                {
                    this.selectedLVItems[num] = (num >= this.lv.draggedTo) && (num < (this.lv.draggedTo + c.Count));
                }
            }
            if ((current.type == EventType.KeyDown) && ((current.keyCode == KeyCode.Backspace) || (current.keyCode == KeyCode.Delete)))
            {
                num2 = 0;
                num = 0;
                while (num < this.selectedLVItems.Length)
                {
                    if (this.selectedLVItems[num])
                    {
                        list.RemoveAt(num2);
                        num2--;
                    }
                    this.selectedLVItems[num] = false;
                    num++;
                    num2++;
                }
                this.lv.row = -1;
                current.Use();
            }
            EditorBuildSettings.scenes = list.ToArray(typeof(EditorBuildSettingsScene)) as EditorBuildSettingsScene[];
        }

        private void AddCurrentScene()
        {
            string currentScene = EditorApplication.currentScene;
            if (currentScene.Length == 0)
            {
                EditorApplication.SaveCurrentSceneIfUserWantsToForce();
                currentScene = EditorApplication.currentScene;
            }
            if (currentScene.Length != 0)
            {
                ArrayList list = new ArrayList(EditorBuildSettings.scenes);
                EditorBuildSettingsScene scene = new EditorBuildSettingsScene {
                    path = currentScene,
                    enabled = true
                };
                list.Add(scene);
                EditorBuildSettings.scenes = list.ToArray(typeof(EditorBuildSettingsScene)) as EditorBuildSettingsScene[];
            }
            base.Repaint();
            GUIUtility.ExitGUI();
        }

        private static void BuildPlayerAndRun()
        {
            if (!BuildPlayerWithDefaultSettings(false, BuildOptions.AutoRunPlayer))
            {
                ShowBuildPlayerWindow();
            }
        }

        private static void BuildPlayerAndSelect()
        {
            if (!BuildPlayerWithDefaultSettings(false, BuildOptions.ShowBuiltPlayer))
            {
                ShowBuildPlayerWindow();
            }
        }

        private static bool BuildPlayerWithDefaultSettings(bool askForBuildLocation, BuildOptions forceOptions)
        {
            return BuildPlayerWithDefaultSettings(askForBuildLocation, forceOptions, true);
        }

        private static bool BuildPlayerWithDefaultSettings(bool askForBuildLocation, BuildOptions forceOptions, bool first)
        {
            if ((first && EditorUserBuildSettings.webPlayerDeployOnline) && !EnsureLoggedInAndBuild(askForBuildLocation, forceOptions))
            {
                return false;
            }
            InitBuildPlatforms();
            BuildTarget target = CalculateSelectedBuildTarget();
            if (!BuildPipeline.IsBuildTargetSupported(target))
            {
                return false;
            }
            if (Unsupported.IsBleedingEdgeBuild())
            {
                StringBuilder builder = new StringBuilder();
                builder.AppendLine("This version of Unity is a BleedingEdge build that has not seen any manual testing.");
                builder.AppendLine("You should consider this build unstable.");
                builder.AppendLine("We strongly recommend that you use a normal version of Unity instead.");
                if (EditorUtility.DisplayDialog("BleedingEdge Build", builder.ToString(), "Cancel", "OK"))
                {
                    return false;
                }
            }
            string path = string.Empty;
            bool flag = (EditorUserBuildSettings.installInBuildFolder && PostprocessBuildPlayer.SupportsInstallInBuildFolder(target)) && Unsupported.IsDeveloperBuild();
            if (!flag)
            {
                if ((EditorUserBuildSettings.selectedBuildTargetGroup == BuildTargetGroup.WebPlayer) && EditorUserBuildSettings.webPlayerDeployOnline)
                {
                    path = Path.Combine(Path.Combine(Path.GetTempPath(), "Unity"), "UDNBuild");
                    try
                    {
                        Directory.CreateDirectory(path);
                    }
                    catch (System.Exception)
                    {
                    }
                    if (!Directory.Exists(path))
                    {
                        Debug.LogError(string.Format("Failed to create temporary build directory at {0}", path));
                        return false;
                    }
                    path = path.Replace('\\', '/');
                }
                else
                {
                    if (askForBuildLocation && !PickBuildLocation(target))
                    {
                        return false;
                    }
                    path = EditorUserBuildSettings.GetBuildLocation(target);
                }
                if ((path.Length == 0) || !Directory.Exists(FileUtil.DeleteLastPathNameComponent(path)))
                {
                    return false;
                }
                if (!askForBuildLocation && InternalEditorUtility.ProjectCanBeAppended(path))
                {
                    EditorUserBuildSettings.appendProject = true;
                }
            }
            ArrayList list = new ArrayList();
            foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
            {
                if (scene.enabled)
                {
                    list.Add(scene.path);
                }
            }
            string[] levels = list.ToArray(typeof(string)) as string[];
            BuildOptions options = forceOptions;
            if (EditorUserBuildSettings.development)
            {
                options |= BuildOptions.Development;
            }
            if (EditorUserBuildSettings.connectProfiler && EditorUserBuildSettings.development)
            {
                options |= BuildOptions.ConnectWithProfiler;
            }
            if (EditorUserBuildSettings.allowDebugging && EditorUserBuildSettings.development)
            {
                options |= BuildOptions.AllowDebugging;
            }
            if (EditorUserBuildSettings.symlinkLibraries)
            {
                options |= BuildOptions.SymlinkLibraries;
            }
            if (EditorUserBuildSettings.appendProject)
            {
                options |= BuildOptions.AcceptExternalModificationsToPlayer;
            }
            if (EditorUserBuildSettings.webPlayerDeployOnline)
            {
                options |= BuildOptions.DeployOnline;
            }
            if (EditorUserBuildSettings.webPlayerOfflineDeployment)
            {
                options |= BuildOptions.WebPlayerOfflineDeployment;
            }
            if (flag)
            {
                options |= BuildOptions.InstallInBuildFolder;
            }
            bool delayToAfterScriptReload = false;
            if (EditorUserBuildSettings.activeBuildTarget != target)
            {
                delayToAfterScriptReload = true;
                EditorUserBuildSettings.SwitchActiveBuildTarget(target);
            }
            return (BuildPipeline.BuildPlayerInternalNoCheck(levels, path, target, options, delayToAfterScriptReload).Length == 0);
        }

        private static BuildTarget CalculateSelectedBuildTarget()
        {
            BuildTargetGroup selectedBuildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
            switch (selectedBuildTargetGroup)
            {
                case BuildTargetGroup.Standalone:
                    return EditorUserBuildSettings.selectedStandaloneTarget;

                case BuildTargetGroup.WebPlayer:
                    return (!EditorUserBuildSettings.webPlayerStreamed ? BuildTarget.WebPlayer : BuildTarget.WebPlayerStreamed);
            }
            if (s_BuildPlatforms == null)
            {
                throw new System.Exception("Build platforms are not initialized.");
            }
            BuildPlatform platform = s_BuildPlatforms.BuildPlatformFromTargetGroup(selectedBuildTargetGroup);
            if (platform == null)
            {
                throw new System.Exception("Could not find build platform for target group " + selectedBuildTargetGroup);
            }
            return platform.DefaultTarget;
        }

        private static bool EnsureLoggedInAndBuild(bool askForBuildLocation, BuildOptions forceOptions)
        {
            <EnsureLoggedInAndBuild>c__AnonStorey8 storey = new <EnsureLoggedInAndBuild>c__AnonStorey8 {
                askForBuildLocation = askForBuildLocation,
                forceOptions = forceOptions
            };
            if (string.IsNullOrEmpty(UploadingBuildsMonitor.GetActiveSessionID()))
            {
                AssetStoreLoginWindow.Login(styles.noSessionDialogText.text, new AssetStoreLoginWindow.LoginCallback(storey.<>m__3));
                return false;
            }
            return true;
        }

        internal static List<BuildPlatform> GetValidPlatforms()
        {
            InitBuildPlatforms();
            List<BuildPlatform> list = new List<BuildPlatform>();
            foreach (BuildPlatform platform in s_BuildPlatforms.buildPlatforms)
            {
                if ((platform.targetGroup == BuildTargetGroup.Standalone) || BuildPipeline.IsBuildTargetSupported(platform.DefaultTarget))
                {
                    list.Add(platform);
                }
            }
            return list;
        }

        private static void GUIBuildButtons(bool enableBuildButton, bool enableBuildAndRunButton, bool canInstallInBuildFolder, BuildPlatform platform)
        {
            GUILayout.FlexibleSpace();
            if (canInstallInBuildFolder)
            {
                EditorUserBuildSettings.installInBuildFolder = GUILayout.Toggle(EditorUserBuildSettings.installInBuildFolder, "Install in Builds folder\n(for debugging with source code)", new GUILayoutOption[0]);
            }
            else
            {
                EditorUserBuildSettings.installInBuildFolder = false;
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            if ((platform.targetGroup == BuildTargetGroup.Android) && EditorUserBuildSettings.appendProject)
            {
                enableBuildAndRunButton = false;
            }
            GUIContent build = styles.build;
            if ((platform.targetGroup == BuildTargetGroup.Android) && EditorUserBuildSettings.appendProject)
            {
                build = styles.export;
            }
            GUI.enabled = enableBuildButton;
            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(110f) };
            if (GUILayout.Button(build, options))
            {
                BuildPlayerWithDefaultSettings(true, BuildOptions.ShowBuiltPlayer);
                GUIUtility.ExitGUI();
            }
            GUI.enabled = enableBuildAndRunButton;
            GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(110f) };
            if (GUILayout.Button(styles.buildAndRun, optionArray2))
            {
                BuildPlayerWithDefaultSettings(true, BuildOptions.AutoRunPlayer);
                GUIUtility.ExitGUI();
            }
            GUILayout.EndHorizontal();
        }

        private static void InitBuildPlatforms()
        {
            if (s_BuildPlatforms == null)
            {
                s_BuildPlatforms = new BuildPlatforms();
                RepairSelectedBuildTargetGroup();
            }
        }

        internal static bool IsBuildTargetGroupSupported(BuildTarget target)
        {
            return ((target == BuildTarget.StandaloneWindows) || BuildPipeline.IsBuildTargetSupported(target));
        }

        internal static bool IsXboxBuildSubtargetDevelopment(XboxBuildSubtarget target)
        {
            return (target != XboxBuildSubtarget.Master);
        }

        private void OnGUI()
        {
            if (styles == null)
            {
                styles = new Styles();
                styles.toggleSize = styles.toggle.CalcSize(new GUIContent("X"));
                this.lv.rowHeight = (int) styles.levelString.CalcHeight(new GUIContent("X"), 100f);
            }
            InitBuildPlatforms();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(10f);
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            string message = string.Empty;
            bool disabled = !AssetDatabase.IsOpenForEdit("Library/Versioned/EditorBuildSettings.asset", out message);
            EditorGUI.BeginDisabledGroup(disabled);
            this.ActiveScenesGUI();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (disabled)
            {
                GUI.enabled = true;
                if (VCProvider.enabled && GUILayout.Button("Checkout", new GUILayoutOption[0]))
                {
                    VCAsset assetByPath = VCDatabase.GetAssetByPath("Library/Versioned/EditorBuildSettings.asset");
                    VCAssetList assets = new VCAssetList {
                        assetByPath
                    };
                    VCProvider.Checkout(assets, CheckoutMode.Both);
                    VCDatabase.Invalidate(assets);
                }
                GUILayout.Label(message, new GUILayoutOption[0]);
                GUI.enabled = false;
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Add Current", new GUILayoutOption[0]))
            {
                this.AddCurrentScene();
            }
            GUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();
            GUILayout.Space(10f);
            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Height(301f) };
            GUILayout.BeginHorizontal(options);
            this.ActiveBuildTargetsGUI();
            GUILayout.Space(10f);
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            this.ShowBuildTargetSettings();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.Space(10f);
            GUILayout.EndVertical();
            GUILayout.Space(10f);
            GUILayout.EndHorizontal();
        }

        private static bool PickBuildLocation(BuildTarget target)
        {
            string buildLocation = EditorUserBuildSettings.GetBuildLocation(target);
            if ((target == BuildTarget.Android) && EditorUserBuildSettings.appendProject)
            {
                string str2 = "Export Eclipse Project";
                string location = EditorUtility.SaveFolderPanel(str2, buildLocation, string.Empty);
                EditorUserBuildSettings.SetBuildLocation(target, location);
                return true;
            }
            string extensionForBuildTarget = PostprocessBuildPlayer.GetExtensionForBuildTarget(target);
            string directory = FileUtil.DeleteLastPathNameComponent(buildLocation);
            string lastPathNameComponent = FileUtil.GetLastPathNameComponent(buildLocation);
            string title = "Build " + s_BuildPlatforms.GetBuildTargetDisplayName(target);
            string path = EditorUtility.SaveBuildPanel(target, title, directory, lastPathNameComponent, extensionForBuildTarget);
            if (path == string.Empty)
            {
                return false;
            }
            if ((extensionForBuildTarget != string.Empty) && (FileUtil.GetPathExtension(path).ToLower() != extensionForBuildTarget))
            {
                path = path + '.' + extensionForBuildTarget;
            }
            if (FileUtil.GetLastPathNameComponent(path) == string.Empty)
            {
                return false;
            }
            string str10 = FileUtil.DeleteLastPathNameComponent(path);
            if (!Directory.Exists(str10))
            {
                Directory.CreateDirectory(str10);
            }
            EditorUserBuildSettings.SetBuildLocation(target, path);
            return true;
        }

        private static void RepairSelectedBuildTargetGroup()
        {
            BuildTargetGroup selectedBuildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
            if (((selectedBuildTargetGroup == BuildTargetGroup.Unknown) || (s_BuildPlatforms == null)) || (s_BuildPlatforms.BuildPlatformIndexFromTargetGroup(selectedBuildTargetGroup) < 0))
            {
                EditorUserBuildSettings.selectedBuildTargetGroup = BuildTargetGroup.WebPlayer;
            }
        }

        private static BuildTarget RestoreLastKnownPlatformsBuildTarget(BuildPlatform bp)
        {
            BuildTargetGroup targetGroup = bp.targetGroup;
            if (targetGroup == BuildTargetGroup.Standalone)
            {
                return EditorUserBuildSettings.selectedStandaloneTarget;
            }
            if (targetGroup != BuildTargetGroup.WebPlayer)
            {
                return bp.DefaultTarget;
            }
            return (!EditorUserBuildSettings.webPlayerStreamed ? BuildTarget.WebPlayer : BuildTarget.WebPlayerStreamed);
        }

        private static void ShowBuildPlayerWindow()
        {
            EditorWindow.GetWindow<BuildPlayerWindow>(true, "Build Settings");
        }

        private void ShowBuildTargetSettings()
        {
            BuildTarget target3;
            Dictionary<GUIContent, BuildTarget> architecturesForPlatform;
            GUIContent[] contentArray;
            int num5;
            EditorGUIUtility.LookLikeControls(Mathf.Min((float) 180f, (float) ((base.position.width - 265f) * 0.47f)));
            BuildTarget target = CalculateSelectedBuildTarget();
            BuildPlatform platform = s_BuildPlatforms.BuildPlatformFromTargetGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
            GUILayout.Space(18f);
            Rect position = GUILayoutUtility.GetRect((float) 50f, (float) 36f);
            position.x++;
            GUI.Label(new Rect(position.x + 3f, position.y + 3f, 32f, 32f), platform.title.image, GUIStyle.none);
            GUI.Toggle(position, false, platform.title.text, styles.platformSelector);
            GUILayout.Space(10f);
            GUIContent downloadErrorForTarget = styles.GetDownloadErrorForTarget(target);
            if (downloadErrorForTarget != null)
            {
                GUILayout.Label(downloadErrorForTarget, EditorStyles.wordWrappedLabel, new GUILayoutOption[0]);
                GUIBuildButtons(false, false, false, platform);
                return;
            }
            if (!BuildPipeline.LicenseCheck(target))
            {
                int num2 = s_BuildPlatforms.BuildPlatformIndexFromTargetGroup(platform.targetGroup);
                GUILayout.Label(styles.notLicensedMessages[num2, 0], EditorStyles.wordWrappedLabel, new GUILayoutOption[0]);
                GUILayout.Space(5f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                if ((styles.notLicensedMessages[num2, 1].text.Length != 0) && GUILayout.Button(styles.notLicensedMessages[num2, 1], new GUILayoutOption[0]))
                {
                    Application.OpenURL(styles.notLicensedMessages[num2, 2].text);
                }
                GUILayout.EndHorizontal();
                GUIBuildButtons(false, false, false, platform);
                return;
            }
            GUI.changed = false;
            switch (platform.targetGroup)
            {
                case BuildTargetGroup.Standalone:
                {
                    BuildTarget selectedStandaloneTarget = EditorUserBuildSettings.selectedStandaloneTarget;
                    int selectedIndex = Math.Max(0, Array.IndexOf<BuildTarget>(s_BuildPlatforms.standaloneSubtargets, BuildPlatforms.DefaultTargetForPlatform(selectedStandaloneTarget)));
                    int index = EditorGUILayout.Popup(styles.standaloneTarget, selectedIndex, s_BuildPlatforms.standaloneSubtargetStrings, new GUILayoutOption[0]);
                    architecturesForPlatform = BuildPlatforms.GetArchitecturesForPlatform(selectedStandaloneTarget);
                    if ((index != selectedIndex) || (architecturesForPlatform == null))
                    {
                        target3 = s_BuildPlatforms.standaloneSubtargets[index];
                        goto Label_03B7;
                    }
                    contentArray = new List<GUIContent>(architecturesForPlatform.Keys).ToArray();
                    num5 = 0;
                    if (index == selectedIndex)
                    {
                        foreach (KeyValuePair<GUIContent, BuildTarget> pair in architecturesForPlatform)
                        {
                            if (((BuildTarget) pair.Value) == selectedStandaloneTarget)
                            {
                                num5 = Math.Max(0, Array.IndexOf<GUIContent>(contentArray, pair.Key));
                                break;
                            }
                        }
                    }
                    break;
                }
                case BuildTargetGroup.WebPlayer:
                {
                    EditorUserBuildSettings.webPlayerDeployOnline = false;
                    GUI.enabled = BuildPipeline.LicenseCheck(BuildTarget.WebPlayerStreamed);
                    bool flag = EditorGUILayout.Toggle(styles.webPlayerStreamed, EditorUserBuildSettings.webPlayerStreamed, new GUILayoutOption[0]);
                    if (GUI.changed)
                    {
                        EditorUserBuildSettings.webPlayerStreamed = flag;
                    }
                    bool enabled = GUI.enabled;
                    if (EditorUserBuildSettings.webPlayerDeployOnline)
                    {
                        GUI.enabled = false;
                    }
                    EditorUserBuildSettings.webPlayerOfflineDeployment = EditorGUILayout.Toggle(styles.webPlayerOfflineDeployment, EditorUserBuildSettings.webPlayerOfflineDeployment, new GUILayoutOption[0]);
                    GUI.enabled = enabled;
                    goto Label_06E7;
                }
                case BuildTargetGroup.Wii:
                {
                    int num8 = Array.IndexOf<WiiBuildSubtarget>(s_BuildPlatforms.wiiBuildSubtargets, EditorUserBuildSettings.wiiBuildSubtarget);
                    if (num8 == -1)
                    {
                        num8 = 0;
                    }
                    num8 = EditorGUILayout.Popup(styles.wiiBuildSubtarget, num8, s_BuildPlatforms.wiiBuildSubtargetStrings, new GUILayoutOption[0]);
                    EditorUserBuildSettings.wiiBuildSubtarget = s_BuildPlatforms.wiiBuildSubtargets[num8];
                    if ((EditorUserBuildSettings.wiiBuildSubtarget != WiiBuildSubtarget.DVD) && (EditorUserBuildSettings.wiiBuildSubtarget != WiiBuildSubtarget.WiiWare))
                    {
                        EditorUserBuildSettings.wiiBuildDebugLevel = WiiBuildDebugLevel.None;
                    }
                    else
                    {
                        num8 = Array.IndexOf<WiiBuildDebugLevel>(s_BuildPlatforms.wiiBuildDebugLevels, EditorUserBuildSettings.wiiBuildDebugLevel);
                        if (num8 == -1)
                        {
                            num8 = 0;
                        }
                        num8 = EditorGUILayout.Popup(styles.wiiBuildDebugLevel, num8, s_BuildPlatforms.wiiBuildDebugLevelStrings, new GUILayoutOption[0]);
                        EditorUserBuildSettings.wiiBuildDebugLevel = s_BuildPlatforms.wiiBuildDebugLevels[num8];
                        GUILayout.Label(s_BuildPlatforms.wiiBuildDebugLevelDescStrings[num8], new GUILayoutOption[0]);
                    }
                    goto Label_06E7;
                }
                case BuildTargetGroup.iPhone:
                    EditorUserBuildSettings.symlinkLibraries = EditorGUILayout.Toggle(styles.symlinkiOSLibraries, EditorUserBuildSettings.symlinkLibraries, new GUILayoutOption[0]);
                    goto Label_06E7;

                case BuildTargetGroup.PS3:
                {
                    int num6 = Array.IndexOf<PS3BuildSubtarget>(s_BuildPlatforms.ps3Subtargets, EditorUserBuildSettings.ps3BuildSubtarget);
                    if (num6 == -1)
                    {
                        num6 = 0;
                    }
                    num6 = EditorGUILayout.Popup(styles.ps3Target, num6, s_BuildPlatforms.ps3SubtargetStrings, new GUILayoutOption[0]);
                    EditorUserBuildSettings.ps3BuildSubtarget = s_BuildPlatforms.ps3Subtargets[num6];
                    goto Label_06E7;
                }
                case BuildTargetGroup.XBOX360:
                {
                    int num9 = Array.IndexOf<XboxBuildSubtarget>(s_BuildPlatforms.xboxBuildSubtargets, EditorUserBuildSettings.xboxBuildSubtarget);
                    if (num9 == -1)
                    {
                        num9 = 0;
                    }
                    num9 = EditorGUILayout.Popup(styles.xboxBuildSubtarget, num9, s_BuildPlatforms.xboxBuildSubtargetStrings, new GUILayoutOption[0]);
                    EditorUserBuildSettings.xboxBuildSubtarget = s_BuildPlatforms.xboxBuildSubtargets[num9];
                    num9 = Array.IndexOf<XboxRunMethod>(s_BuildPlatforms.xboxRunMethods, EditorUserBuildSettings.xboxRunMethod);
                    if (num9 == -1)
                    {
                        num9 = 0;
                    }
                    num9 = EditorGUILayout.Popup(styles.xboxRunMethod, num9, s_BuildPlatforms.xboxRunMethodStrings, new GUILayoutOption[0]);
                    EditorUserBuildSettings.xboxRunMethod = s_BuildPlatforms.xboxRunMethods[num9];
                    goto Label_06E7;
                }
                case BuildTargetGroup.Android:
                {
                    int num7 = Array.IndexOf<AndroidBuildSubtarget>(s_BuildPlatforms.androidBuildSubtargets, EditorUserBuildSettings.androidBuildSubtarget);
                    if (num7 == -1)
                    {
                        num7 = 0;
                    }
                    num7 = EditorGUILayout.Popup(styles.androidBuildSubtarget, num7, s_BuildPlatforms.androidBuildSubtargetStrings, new GUILayoutOption[0]);
                    EditorUserBuildSettings.androidBuildSubtarget = s_BuildPlatforms.androidBuildSubtargets[num7];
                    bool flag3 = EditorUserBuildSettings.installInBuildFolder && PostprocessBuildPlayer.SupportsInstallInBuildFolder(target);
                    bool flag11 = !flag3;
                    GUI.enabled = flag11;
                    EditorUserBuildSettings.appendProject &= flag11;
                    EditorUserBuildSettings.appendProject = EditorGUILayout.Toggle(styles.createProject, EditorUserBuildSettings.appendProject, new GUILayoutOption[0]);
                    GUI.enabled = true;
                    goto Label_06E7;
                }
                case BuildTargetGroup.FlashPlayer:
                {
                    int num10 = Array.IndexOf<FlashBuildSubtarget>(s_BuildPlatforms.flashBuildSubtargets, EditorUserBuildSettings.flashBuildSubtarget);
                    if (num10 == -1)
                    {
                        num10 = 0;
                    }
                    num10 = EditorGUILayout.Popup(styles.flashTarget, num10, s_BuildPlatforms.flashBuildSubtargetString, new GUILayoutOption[0]);
                    EditorUserBuildSettings.flashBuildSubtarget = s_BuildPlatforms.flashBuildSubtargets[num10];
                    goto Label_06E7;
                }
                default:
                    goto Label_06E7;
            }
            num5 = EditorGUILayout.Popup(styles.architecture, num5, contentArray, new GUILayoutOption[0]);
            target3 = architecturesForPlatform[contentArray[num5]];
        Label_03B7:
            EditorUserBuildSettings.selectedStandaloneTarget = target3;
        Label_06E7:
            GUI.enabled = true;
            bool enableBuildButton = false;
            bool enableBuildAndRunButton = false;
            bool flag6 = ((target != BuildTarget.Wii) && (target != BuildTarget.FlashPlayer)) && (target != BuildTarget.NaCl);
            bool flag7 = (((target != BuildTarget.Wii) && (target != BuildTarget.PS3)) && (target != BuildTarget.FlashPlayer)) && (target != BuildTarget.NaCl);
            bool flag8 = (target == BuildTarget.XBOX360) || (target == BuildTarget.PS3);
            bool canInstallInBuildFolder = false;
            if (!BuildPipeline.IsBuildTargetSupported(target))
            {
                GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.ExpandWidth(true) };
                GUILayout.BeginHorizontal(options);
                GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.ExpandWidth(true) };
                GUILayout.BeginVertical(optionArray2);
                int num11 = s_BuildPlatforms.BuildPlatformIndexFromTargetGroup(platform.targetGroup);
                GUILayout.Label(styles.buildTargetNotInstalled[num11, 0], new GUILayoutOption[0]);
                if ((styles.buildTargetNotInstalled[num11, 1] != null) && GUILayout.Button(styles.buildTargetNotInstalled[num11, 1], new GUILayoutOption[0]))
                {
                    Application.OpenURL(styles.buildTargetNotInstalled[num11, 2].text);
                }
                GUILayout.EndVertical();
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
            else
            {
                bool flag10 = (target == BuildTarget.PS3) && (EditorUserBuildSettings.ps3BuildSubtarget != PS3BuildSubtarget.PCHosted);
                switch (platform.targetGroup)
                {
                    case BuildTargetGroup.Wii:
                        EditorUserBuildSettings.development = EditorUserBuildSettings.wiiBuildDebugLevel != WiiBuildDebugLevel.None;
                        break;

                    case BuildTargetGroup.XBOX360:
                        EditorUserBuildSettings.development = IsXboxBuildSubtargetDevelopment(EditorUserBuildSettings.xboxBuildSubtarget);
                        break;

                    default:
                        EditorUserBuildSettings.development = EditorGUILayout.Toggle(styles.debugBuild, EditorUserBuildSettings.development, new GUILayoutOption[0]);
                        break;
                }
                GUI.enabled = EditorUserBuildSettings.development;
                GUI.enabled = GUI.enabled && InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(target);
                if (flag6)
                {
                    EditorUserBuildSettings.connectProfiler = EditorGUILayout.Toggle(styles.profileBuild, EditorUserBuildSettings.connectProfiler, new GUILayoutOption[0]);
                }
                GUI.enabled = EditorUserBuildSettings.development;
                if (flag7)
                {
                    EditorUserBuildSettings.allowDebugging = EditorGUILayout.Toggle(styles.allowDebugging, EditorUserBuildSettings.allowDebugging, new GUILayoutOption[0]);
                }
                if (flag8)
                {
                    EditorUserBuildSettings.explicitNullChecks = EditorGUILayout.Toggle(styles.explicitNullChecks, EditorUserBuildSettings.explicitNullChecks, new GUILayoutOption[0]);
                }
                GUI.enabled = true;
                GUILayout.FlexibleSpace();
                canInstallInBuildFolder = (!flag10 && Unsupported.IsDeveloperBuild()) && ((((target != BuildTarget.XBOX360) && (target != BuildTarget.Wii)) && ((target != BuildTarget.FlashPlayer) && (target != BuildTarget.iPhone))) && (target != BuildTarget.NaCl));
                enableBuildButton = true;
                enableBuildAndRunButton = !(flag10 || EditorUserBuildSettings.installInBuildFolder);
            }
            GUIBuildButtons(enableBuildButton, enableBuildAndRunButton, canInstallInBuildFolder, platform);
        }

        private void ShowOption(BuildPlatform bp, GUIContent title, GUIStyle background)
        {
            Rect position = GUILayoutUtility.GetRect((float) 50f, (float) 36f);
            position.x++;
            position.y++;
            bool flag = BuildPipeline.LicenseCheck(bp.DefaultTarget);
            GUI.contentColor = new Color(1f, 1f, 1f, !flag ? 0.7f : 1f);
            bool on = EditorUserBuildSettings.selectedBuildTargetGroup == bp.targetGroup;
            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(position, GUIContent.none, false, false, on, false);
                GUI.Label(new Rect(position.x + 3f, position.y + 3f, 32f, 32f), title.image, GUIStyle.none);
                if (BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget) == bp.targetGroup)
                {
                    GUI.Label(new Rect((position.xMax - styles.activePlatformIcon.width) - 8f, (position.y + 3f) + ((0x20 - styles.activePlatformIcon.height) / 2), (float) styles.activePlatformIcon.width, (float) styles.activePlatformIcon.height), styles.activePlatformIcon, GUIStyle.none);
                }
            }
            if (GUI.Toggle(position, on, title.text, styles.platformSelector) && (EditorUserBuildSettings.selectedBuildTargetGroup != bp.targetGroup))
            {
                EditorUserBuildSettings.selectedBuildTargetGroup = bp.targetGroup;
                UnityEngine.Object[] objArray = Resources.FindObjectsOfTypeAll(typeof(InspectorWindow));
                for (int i = 0; i < objArray.Length; i++)
                {
                    InspectorWindow window = objArray[i] as InspectorWindow;
                    if (window != null)
                    {
                        window.Repaint();
                    }
                }
            }
        }

        [CompilerGenerated]
        private sealed class <EnsureLoggedInAndBuild>c__AnonStorey8
        {
            internal bool askForBuildLocation;
            internal BuildOptions forceOptions;

            internal void <>m__3(string errorMessage)
            {
                if (string.IsNullOrEmpty(errorMessage))
                {
                    BuildPlayerWindow.BuildPlayerWithDefaultSettings(this.askForBuildLocation, this.forceOptions, false);
                }
                else
                {
                    Debug.LogError(errorMessage);
                }
            }
        }

        public class BuildPlatform
        {
            public bool forceShowTarget;
            public string name;
            public Texture2D smallIcon;
            public BuildTargetGroup targetGroup;
            public GUIContent title;

            public BuildPlatform(string locTitle, BuildTargetGroup targetGroup, bool forceShowTarget)
            {
                this.targetGroup = targetGroup;
                this.name = BuildPipeline.GetBuildTargetGroupName(this.DefaultTarget);
                this.title = EditorGUIUtility.TextContent(locTitle);
                this.smallIcon = EditorGUIUtility.IconContent(locTitle + ".Small").image as Texture2D;
                this.forceShowTarget = forceShowTarget;
            }

            public BuildTarget DefaultTarget
            {
                get
                {
                    switch (this.targetGroup)
                    {
                        case BuildTargetGroup.Standalone:
                            return BuildTarget.StandaloneWindows;

                        case BuildTargetGroup.WebPlayer:
                            return BuildTarget.WebPlayer;

                        case BuildTargetGroup.Wii:
                            return BuildTarget.Wii;

                        case BuildTargetGroup.iPhone:
                            return BuildTarget.iPhone;

                        case BuildTargetGroup.PS3:
                            return BuildTarget.PS3;

                        case BuildTargetGroup.XBOX360:
                            return BuildTarget.XBOX360;

                        case BuildTargetGroup.Android:
                            return BuildTarget.Android;

                        case BuildTargetGroup.GLESEmu:
                            return BuildTarget.StandaloneGLESEmu;

                        case BuildTargetGroup.NaCl:
                            return BuildTarget.NaCl;

                        case BuildTargetGroup.FlashPlayer:
                            return BuildTarget.FlashPlayer;
                    }
                    return (BuildTarget) (-1);
                }
            }
        }

        private class BuildPlatforms
        {
            public AndroidBuildSubtarget[] androidBuildSubtargets;
            public GUIContent[] androidBuildSubtargetStrings;
            public BuildPlayerWindow.BuildPlatform[] buildPlatforms;
            public FlashBuildSubtarget[] flashBuildSubtargets;
            public GUIContent[] flashBuildSubtargetString;
            public PS3BuildSubtarget[] ps3Subtargets;
            public GUIContent[] ps3SubtargetStrings;
            public BuildTarget[] standaloneSubtargets;
            public GUIContent[] standaloneSubtargetStrings;
            public GUIContent[] wiiBuildDebugLevelDescStrings;
            public WiiBuildDebugLevel[] wiiBuildDebugLevels;
            public GUIContent[] wiiBuildDebugLevelStrings;
            public WiiBuildSubtarget[] wiiBuildSubtargets;
            public GUIContent[] wiiBuildSubtargetStrings;
            public XboxBuildSubtarget[] xboxBuildSubtargets;
            public GUIContent[] xboxBuildSubtargetStrings;
            public XboxRunMethod[] xboxRunMethods;
            public GUIContent[] xboxRunMethodStrings;

            internal BuildPlatforms()
            {
                PS3BuildSubtarget[] subtargetArray1 = new PS3BuildSubtarget[3];
                subtargetArray1[1] = PS3BuildSubtarget.HddTitle;
                subtargetArray1[2] = PS3BuildSubtarget.BluRayTitle;
                this.ps3Subtargets = subtargetArray1;
                this.ps3SubtargetStrings = new GUIContent[] { EditorGUIUtility.TextContent("BuildSettings.PS3BuildSubtargetPCHosted"), EditorGUIUtility.TextContent("BuildSettings.PS3BuildSubtargetHddTitle"), EditorGUIUtility.TextContent("BuildSettings.PS3BuildSubtargetBluRayTitle") };
                WiiBuildSubtarget[] subtargetArray2 = new WiiBuildSubtarget[4];
                subtargetArray2[1] = WiiBuildSubtarget.WiiWare;
                subtargetArray2[2] = WiiBuildSubtarget.DVDLibrary;
                subtargetArray2[3] = WiiBuildSubtarget.WiiWareLibrary;
                this.wiiBuildSubtargets = subtargetArray2;
                this.wiiBuildSubtargetStrings = new GUIContent[] { EditorGUIUtility.TextContent("BuildSettings.WiiBuildSubtargetDVD"), EditorGUIUtility.TextContent("BuildSettings.WiiBuildSubtargetWiiWare"), EditorGUIUtility.TextContent("BuildSettings.WiiBuildSubtargetDVDLibrary"), EditorGUIUtility.TextContent("BuildSettings.WiiBuildSubtargetWiiWareLibrary") };
                WiiBuildDebugLevel[] levelArray1 = new WiiBuildDebugLevel[3];
                levelArray1[1] = WiiBuildDebugLevel.Minimal;
                levelArray1[2] = WiiBuildDebugLevel.None;
                this.wiiBuildDebugLevels = levelArray1;
                this.wiiBuildDebugLevelStrings = new GUIContent[] { EditorGUIUtility.TextContent("BuildSettings.WiiBuildDebugLevelFull"), EditorGUIUtility.TextContent("BuildSettings.WiiBuildDebugLevelMinimal"), EditorGUIUtility.TextContent("BuildSettings.WiiBuildDebugLevelNone") };
                this.wiiBuildDebugLevelDescStrings = new GUIContent[] { EditorGUIUtility.TextContent("BuildSettings.WiiBuildDebugLevelFullDesc"), EditorGUIUtility.TextContent("BuildSettings.WiiBuildDebugLevelMinimalDesc"), EditorGUIUtility.TextContent("BuildSettings.WiiBuildDebugLevelNoneDesc") };
                FlashBuildSubtarget[] subtargetArray3 = new FlashBuildSubtarget[3];
                subtargetArray3[1] = FlashBuildSubtarget.Flash11dot3;
                subtargetArray3[2] = FlashBuildSubtarget.Flash11dot4;
                this.flashBuildSubtargets = subtargetArray3;
                this.flashBuildSubtargetString = new GUIContent[] { EditorGUIUtility.TextContent("BuildSettings.FlashSubtarget11dot2"), EditorGUIUtility.TextContent("BuildSettings.FlashSubtarget11dot3"), EditorGUIUtility.TextContent("BuildSettings.FlashSubtarget11dot4") };
                XboxBuildSubtarget[] subtargetArray4 = new XboxBuildSubtarget[3];
                subtargetArray4[1] = XboxBuildSubtarget.Master;
                subtargetArray4[2] = XboxBuildSubtarget.Debug;
                this.xboxBuildSubtargets = subtargetArray4;
                this.xboxBuildSubtargetStrings = new GUIContent[] { EditorGUIUtility.TextContent("BuildSettings.XboxBuildSubtargetDevelopment"), EditorGUIUtility.TextContent("BuildSettings.XboxBuildSubtargetMaster"), EditorGUIUtility.TextContent("BuildSettings.XboxBuildSubtargetDebug") };
                XboxRunMethod[] methodArray1 = new XboxRunMethod[3];
                methodArray1[1] = XboxRunMethod.DiscEmuFast;
                methodArray1[2] = XboxRunMethod.DiscEmuAccurate;
                this.xboxRunMethods = methodArray1;
                this.xboxRunMethodStrings = new GUIContent[] { EditorGUIUtility.TextContent("BuildSettings.XboxRunMethodHDD"), EditorGUIUtility.TextContent("BuildSettings.XboxRunMethodDiscEmuFast"), EditorGUIUtility.TextContent("BuildSettings.XboxRunMethodDiscEmuAccurate") };
                AndroidBuildSubtarget[] subtargetArray5 = new AndroidBuildSubtarget[5];
                subtargetArray5[1] = AndroidBuildSubtarget.DXT;
                subtargetArray5[2] = AndroidBuildSubtarget.PVRTC;
                subtargetArray5[3] = AndroidBuildSubtarget.ATC;
                subtargetArray5[4] = AndroidBuildSubtarget.ETC;
                this.androidBuildSubtargets = subtargetArray5;
                this.androidBuildSubtargetStrings = new GUIContent[] { EditorGUIUtility.TextContent("BuildSettings.AndroidBuildSubtargetGeneric"), EditorGUIUtility.TextContent("BuildSettings.AndroidBuildSubtargetDXT"), EditorGUIUtility.TextContent("BuildSettings.AndroidBuildSubtargetPVRTC"), EditorGUIUtility.TextContent("BuildSettings.AndroidBuildSubtargetATC"), EditorGUIUtility.TextContent("BuildSettings.AndroidBuildSubtargetETC") };
                List<BuildPlayerWindow.BuildPlatform> list = new List<BuildPlayerWindow.BuildPlatform> {
                    new BuildPlayerWindow.BuildPlatform("BuildSettings.Web", 2, 1),
                    new BuildPlayerWindow.BuildPlatform("BuildSettings.Standalone", 1, 1),
                    new BuildPlayerWindow.BuildPlatform("BuildSettings.iPhone", 4, 1),
                    new BuildPlayerWindow.BuildPlatform("BuildSettings.Android", 7, 1),
                    new BuildPlayerWindow.BuildPlatform("BuildSettings.XBox360", 6, 1),
                    new BuildPlayerWindow.BuildPlatform("BuildSettings.PS3", 5, 1),
                    new BuildPlayerWindow.BuildPlatform("BuildSettings.Wii", 3, 1),
                    new BuildPlayerWindow.BuildPlatform("BuildSettings.StandaloneGLESEmu", 9, 0),
                    new BuildPlayerWindow.BuildPlatform("BuildSettings.FlashPlayer", 12, 0),
                    new BuildPlayerWindow.BuildPlatform("BuildSettings.NaCl", 11, 0)
                };
                List<BuildTarget> list2 = new List<BuildTarget> { 5, 4, 0x11 };
                List<GUIContent> list3 = new List<GUIContent> {
                    EditorGUIUtility.TextContent("BuildSettings.StandaloneWindows"),
                    EditorGUIUtility.TextContent("BuildSettings.StandaloneOSXIntel"),
                    EditorGUIUtility.TextContent("BuildSettings.StandaloneLinux")
                };
                this.buildPlatforms = list.ToArray();
                this.standaloneSubtargets = list2.ToArray();
                this.standaloneSubtargetStrings = list3.ToArray();
            }

            public BuildPlayerWindow.BuildPlatform BuildPlatformFromTargetGroup(BuildTargetGroup group)
            {
                int index = this.BuildPlatformIndexFromTargetGroup(group);
                return ((index == -1) ? null : this.buildPlatforms[index]);
            }

            public int BuildPlatformIndexFromTargetGroup(BuildTargetGroup group)
            {
                for (int i = 0; i < this.buildPlatforms.Length; i++)
                {
                    if (group == this.buildPlatforms[i].targetGroup)
                    {
                        return i;
                    }
                }
                return -1;
            }

            public static BuildTarget DefaultTargetForPlatform(BuildTarget target)
            {
                BuildTarget target2 = target;
                switch (target2)
                {
                    case BuildTarget.StandaloneLinux:
                        goto Label_003C;

                    case BuildTarget.StandaloneWindows64:
                        break;

                    default:
                        switch (target2)
                        {
                            case BuildTarget.StandaloneOSXIntel:
                                return BuildTarget.StandaloneOSXIntel;

                            case BuildTarget.StandaloneWindows:
                                break;

                            case BuildTarget.StandaloneLinux64:
                            case BuildTarget.StandaloneLinuxUniversal:
                                goto Label_003C;

                            default:
                                return BuildTarget.StandaloneWindows;
                        }
                        break;
                }
                return BuildTarget.StandaloneWindows;
            Label_003C:
                return BuildTarget.StandaloneLinux;
            }

            public static Dictionary<GUIContent, BuildTarget> GetArchitecturesForPlatform(BuildTarget target)
            {
                Dictionary<GUIContent, BuildTarget> dictionary;
                BuildTarget target2 = target;
                switch (target2)
                {
                    case BuildTarget.StandaloneLinux:
                        goto Label_0065;

                    case BuildTarget.StandaloneWindows64:
                        break;

                    default:
                        switch (target2)
                        {
                            case BuildTarget.StandaloneOSXIntel:
                                dictionary = new Dictionary<GUIContent, BuildTarget>();
                                dictionary.Add(EditorGUIUtility.TextContent("x86"), BuildTarget.StandaloneOSXIntel);
                                return dictionary;

                            case BuildTarget.StandaloneWindows:
                                break;

                            case BuildTarget.StandaloneLinux64:
                            case BuildTarget.StandaloneLinuxUniversal:
                                goto Label_0065;

                            default:
                                return null;
                        }
                        break;
                }
                dictionary = new Dictionary<GUIContent, BuildTarget>();
                dictionary.Add(EditorGUIUtility.TextContent("x86"), BuildTarget.StandaloneWindows);
                dictionary.Add(EditorGUIUtility.TextContent("x86_64"), BuildTarget.StandaloneWindows64);
                return dictionary;
            Label_0065:
                dictionary = new Dictionary<GUIContent, BuildTarget>();
                dictionary.Add(EditorGUIUtility.TextContent("x86"), BuildTarget.StandaloneLinux);
                dictionary.Add(EditorGUIUtility.TextContent("x86_64"), BuildTarget.StandaloneLinux64);
                dictionary.Add(EditorGUIUtility.TextContent("x86 + x 86_64 (Universal)"), BuildTarget.StandaloneLinuxUniversal);
                return dictionary;
            }

            public string GetBuildTargetDisplayName(BuildTarget target)
            {
                foreach (BuildPlayerWindow.BuildPlatform platform in this.buildPlatforms)
                {
                    if (platform.DefaultTarget == target)
                    {
                        return platform.title.text;
                    }
                }
                if (target == BuildTarget.WebPlayerStreamed)
                {
                    return this.BuildPlatformFromTargetGroup(BuildTargetGroup.WebPlayer).title.text;
                }
                for (int i = 0; i < this.standaloneSubtargets.Length; i++)
                {
                    if (this.standaloneSubtargets[i] == target)
                    {
                        return this.standaloneSubtargetStrings[i].text;
                    }
                }
                return "Unsupported Target";
            }
        }

        private class ScenePostprocessor : AssetPostprocessor
        {
            private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath)
            {
                EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes;
                for (int i = 0; i < movedAssets.Length; i++)
                {
                    string path = movedAssets[i];
                    if (Path.GetExtension(path) == ".unity")
                    {
                        foreach (EditorBuildSettingsScene scene in scenes)
                        {
                            if (scene.path.ToLower() == movedFromPath[i].ToLower())
                            {
                                scene.path = path;
                            }
                        }
                    }
                }
                EditorBuildSettings.scenes = scenes;
            }
        }

        public class SceneSorter : IComparer
        {
            int IComparer.Compare(object x, object y)
            {
                return new CaseInsensitiveComparer().Compare(y, x);
            }
        }

        private class Styles
        {
            public Texture2D activePlatformIcon = (EditorGUIUtility.IconContent("BuildSettings.SelectedIcon").image as Texture2D);
            public GUIContent allowDebugging;
            public GUIContent androidBuildSubtarget;
            public GUIContent architecture;
            public GUIStyle box = "OL Box";
            public GUIContent build = EditorGUIUtility.TextContent("BuildSettings.Build");
            public GUIContent buildAndRun = EditorGUIUtility.TextContent("BuildSettings.BuildAndRun");
            public GUIContent[,] buildTargetNotInstalled;
            public GUIContent createProject;
            public GUIContent debugBuild;
            public GUIStyle evenRow = "CN EntryBackEven";
            public GUIContent explicitNullChecks;
            public GUIContent export = EditorGUIUtility.TextContent("BuildSettings.Export");
            public GUIContent flashTarget;
            public const float kButtonWidth = 110f;
            private const string kDownloadURL = "http://unity3d.com/unity/download/";
            private const string kMailURL = "mailto:sales@unity3d.com";
            private const string kShopURL = "https://store.unity3d.com/shop/";
            public GUIStyle levelString = "PlayerSettingsLevel";
            private GUIContent m_WindowsIphoneError;
            public GUIContent metroBuildType;
            public GUIContent noSessionDialogText = EditorGUIUtility.TextContent("UploadingBuildsMonitor.NoSessionDialogText");
            public GUIContent[,] notLicensedMessages;
            public GUIStyle oddRow = "CN EntryBackOdd";
            public GUIStyle platformSelector = "PlayerSettingsPlatform";
            public GUIContent platformTitle = EditorGUIUtility.TextContent("BuildSettings.PlatformTitle");
            public GUIContent profileBuild;
            public GUIContent ps3Target;
            public GUIContent scenesInBuild = EditorGUIUtility.TextContent("BuildSettings.ScenesInBuild");
            public GUIStyle selected = "ServerUpdateChangesetOn";
            public GUIContent standaloneTarget;
            public GUIContent switchPlatform = EditorGUIUtility.TextContent("BuildSettings.SwitchPlatform");
            public GUIContent symlinkiOSLibraries;
            public GUIStyle title = "OL title";
            public GUIStyle toggle = "Toggle";
            public Vector2 toggleSize;
            public GUIContent webPlayerOfflineDeployment;
            public GUIContent webPlayerStreamed;
            public GUIContent wiiBuildDebugLevel;
            public GUIContent wiiBuildSubtarget;
            public GUIContent xboxBuildSubtarget;
            public GUIContent xboxRunMethod;

            public Styles()
            {
                GUIContent[] contentArray1 = new GUIContent[,] { { EditorGUIUtility.TextContent("BuildSettings.NoWeb"), EditorGUIUtility.TextContent("BuildSettings.NoWebButton"), new GUIContent("https://store.unity3d.com/shop/") }, { EditorGUIUtility.TextContent("BuildSettings.NoStandalone"), EditorGUIUtility.TextContent("BuildSettings.NoWebButton"), new GUIContent("https://store.unity3d.com/shop/") }, { EditorGUIUtility.TextContent("BuildSettings.NoiPhone"), EditorGUIUtility.TextContent("BuildSettings.NoiPhoneButton"), new GUIContent("https://store.unity3d.com/shop/") }, { EditorGUIUtility.TextContent("BuildSettings.NoAndroid"), EditorGUIUtility.TextContent("BuildSettings.NoAndroidButton"), new GUIContent("https://store.unity3d.com/shop/") }, { EditorGUIUtility.TextContent("BuildSettings.NoXBox360"), EditorGUIUtility.TextContent("BuildSettings.NoXBox360Button"), new GUIContent("mailto:sales@unity3d.com") }, { EditorGUIUtility.TextContent("BuildSettings.NoPS3"), EditorGUIUtility.TextContent("BuildSettings.NoPS3Button"), new GUIContent("mailto:sales@unity3d.com") }, { EditorGUIUtility.TextContent("BuildSettings.NoWii"), EditorGUIUtility.TextContent("BuildSettings.NoWiiButton"), new GUIContent("mailto:sales@unity3d.com") }, { EditorGUIUtility.TextContent("BuildSettings.NoGLESEmu"), EditorGUIUtility.TextContent("BuildSettings.NoGLESEmuButton"), new GUIContent("mailto:sales@unity3d.com") }, { EditorGUIUtility.TextContent("BuildSettings.NoSecretPlatform"), EditorGUIUtility.TextContent("BuildSettings.NoSecretPlatformButton"), new GUIContent("mailto:sales@unity3d.com") } };
                this.notLicensedMessages = contentArray1;
                GUIContent[] contentArray2 = new GUIContent[9, 3];
                contentArray2[0, 0] = EditorGUIUtility.TextContent("BuildSettings.WebNotInstalled");
                contentArray2[0, 2] = new GUIContent("http://unity3d.com/unity/download/");
                contentArray2[1, 0] = EditorGUIUtility.TextContent("BuildSettings.StandaloneNotInstalled");
                contentArray2[1, 2] = new GUIContent("http://unity3d.com/unity/download/");
                contentArray2[2, 0] = EditorGUIUtility.TextContent("BuildSettings.iPhoneNotInstalled");
                contentArray2[2, 2] = new GUIContent("http://unity3d.com/unity/download/");
                contentArray2[3, 0] = EditorGUIUtility.TextContent("BuildSettings.AndroidNotInstalled");
                contentArray2[3, 2] = new GUIContent("http://unity3d.com/unity/download/");
                contentArray2[4, 0] = EditorGUIUtility.TextContent("BuildSettings.XBOX360NotInstalled");
                contentArray2[4, 2] = new GUIContent("http://unity3d.com/unity/download/");
                contentArray2[5, 0] = EditorGUIUtility.TextContent("BuildSettings.PS3NotInstalled");
                contentArray2[5, 2] = new GUIContent("http://unity3d.com/unity/download/");
                contentArray2[6, 0] = EditorGUIUtility.TextContent("BuildSettings.WiiNotInstalled");
                contentArray2[6, 2] = new GUIContent("http://unity3d.com/unity/download/");
                contentArray2[7, 0] = EditorGUIUtility.TextContent("BuildSettings.GLESEmuNotInstalled");
                contentArray2[7, 2] = new GUIContent("http://unity3d.com/unity/download/");
                contentArray2[8, 0] = EditorGUIUtility.TextContent("BuildSettings.SecretPlatformNotInstalled");
                contentArray2[8, 2] = new GUIContent("http://unity3d.com/unity/download/");
                this.buildTargetNotInstalled = contentArray2;
                this.m_WindowsIphoneError = EditorGUIUtility.TextContent("BuildSettings.iPhoneNotAllowedWindows");
                this.ps3Target = EditorGUIUtility.TextContent("BuildSettings.PS3BuildSubtarget");
                this.flashTarget = EditorGUIUtility.TextContent("BuildSettings.FlashBuildSubtarget");
                this.metroBuildType = EditorGUIUtility.TextContent("BuildSettings.MetroBuildType");
                this.standaloneTarget = EditorGUIUtility.TextContent("BuildSettings.StandaloneTarget");
                this.architecture = EditorGUIUtility.TextContent("BuildSettings.Architecture");
                this.webPlayerStreamed = EditorGUIUtility.TextContent("BuildSettings.WebPlayerStreamed");
                this.webPlayerOfflineDeployment = EditorGUIUtility.TextContent("BuildSettings.WebPlayerOfflineDeployment");
                this.debugBuild = EditorGUIUtility.TextContent("BuildSettings.DebugBuild");
                this.profileBuild = EditorGUIUtility.TextContent("BuildSettings.ConnectProfiler");
                this.allowDebugging = EditorGUIUtility.TextContent("BuildSettings.AllowDebugging");
                this.createProject = EditorGUIUtility.TextContent("BuildSettings.CreateEclipseProject");
                this.symlinkiOSLibraries = EditorGUIUtility.TextContent("BuildSettings.SymlinkiOSLibraries");
                this.wiiBuildSubtarget = EditorGUIUtility.TextContent("BuildSettings.WiiBuildSubtarget");
                this.wiiBuildDebugLevel = EditorGUIUtility.TextContent("BuildSettings.WiiBuildDebugLevel");
                this.xboxBuildSubtarget = EditorGUIUtility.TextContent("BuildSettings.XboxBuildSubtarget");
                this.xboxRunMethod = EditorGUIUtility.TextContent("BuildSettings.XboxRunMethod");
                this.androidBuildSubtarget = EditorGUIUtility.TextContent("BuildSettings.AndroidBuildSubtarget");
                this.explicitNullChecks = EditorGUIUtility.TextContent("BuildSettings.ExplicitNullChecks");
            }

            public GUIContent GetDownloadErrorForTarget(BuildTarget target)
            {
                if ((target == BuildTarget.iPhone) && (Application.platform != RuntimePlatform.OSXEditor))
                {
                    return this.m_WindowsIphoneError;
                }
                return null;
            }
        }
    }
}

